/**
 * 添加或者修改页面
 */
var ThirdManagementStatisticsInfoDlg = {
    data: {
        status: "",
        orderNumber: "",
        dates: "",
        starting: "",
        ends: "",
        freight: "",
        informationFee: "",
        goodsName: "",
        carNumber: "",
        driver: "",
        tel: "",
        remarks: "",
        v1: "",
        v2: "",
        v3: "",
        v4: "",
        deptId: "",
        deliverId: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //执行一个laydate实例
    laydate.render({
      elem: '#dates' //指定元素
        	,value:new Date()
    });

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/thirdManagementStatistics/addItem", function (data) {
    		if (data.success) {
            	Feng.success("添加成功！");
		    	var Index = parent.layer.getFrameIndex(window.name);
		        parent.layer.close(Index);
			} else {
                Feng.error("添加失败！"+data.message);
			}
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    
    $("#freight").keyup(function(){
		var waiMoney = $("#waiMoney").val();//外调车运费
		if(waiMoney != '' && waiMoney != null){
			var freight = $("#freight").val();//总运费
			$("#profit").val(freight-waiMoney)
		} else {
			var freight = $("#freight").val();//总运费
			var fuMoney = $("#fuMoney").val();//付运费
			var informationFee = $("#informationFee").val();//信息费
			var profit =  freight-fuMoney-informationFee
			$("#profit").val(profit)
		}
    });
    
    $("#fuMoney").keyup(function(){
		var freight = $("#freight").val();//总运费
		var fuMoney = $("#fuMoney").val();//付运费
		var informationFee = $("#informationFee").val();//信息费
		var profit =  freight-fuMoney-informationFee
		$("#profit").val(profit)
    });
    
    $("#informationFee").keyup(function(){
		var freight = $("#freight").val();//总运费
		var fuMoney = $("#fuMoney").val();//付运费
		var informationFee = $("#informationFee").val();//信息费
		var profit =  freight-fuMoney-informationFee
		$("#profit").val(profit)
    });

    $("#waiMoney").keyup(function(){
		var freight = $("#freight").val();//总运费
		var waiMoney = $("#waiMoney").val();//外调车运费
		$("#profit").val(freight-waiMoney)
    });

    //返回按钮
    $("#backupPage").click(function () {
	    	var Index = parent.layer.getFrameIndex(window.name);
	        parent.layer.close(Index);
    });

});